import 'package:flutter/material.dart';

class BtLoadingDialog extends StatelessWidget {
  const BtLoadingDialog({Key? key, this.text, this.width, this.height, this.color, this.contentPadding = 20})
      : super(key: key);

  final Widget? text;
  final double? width;
  final double? height;
  final Color? color;
  final double contentPadding;

  @override
  Widget build(BuildContext context) {
    Widget? textWidget;
    if (text != null) {
      textWidget = Padding(
        padding: EdgeInsets.only(top: contentPadding),
        child: DefaultTextStyle(
          style: const TextStyle(),
          child: text!,
        ),
      );
    }
    return Center(
      child: Container(
        width: width ?? 120.0,
        height: height ?? 120.0,
        decoration: ShapeDecoration(
          color: Theme.of(context).brightness == Brightness.light ? Colors.white : Colors.greenAccent,
          shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(
              Radius.circular(10.0),
            ),
          ),
        ),
        padding: EdgeInsets.all(contentPadding),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            const CircularProgressIndicator(),
            if (textWidget != null) textWidget,
          ],
        ),
      ),
    );
  }
}
